import 'package:flutter/material.dart';
import 'package:testui/test04/container/Learnpadding.dart';
import 'package:testui/test04/container/LearnClip.dart';
import 'package:testui/test04/container/LearnContainer.dart';
import 'package:testui/test04/container/learnDecoratedBox.dart';
import 'package:testui/test04/container/LearnFittedBoxr.dart';
import 'package:testui/test04/container/LearnTransform.dart';

///
///
/// 关于容器的，包含单一子控件的布局
///
class AllContainerListPage extends StatelessWidget{
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      appBar: AppBar(
        title: Text("容器类控件"),
      ),
      body: getItemList(),
    );
  }


}

getItemList() {
  var list = ["填充（Padding）","装饰容器（DecoratedBox）","变换（Transform）",
  "容器组件（Container）","剪裁（Clip）","空间适配（FittedBox）"];

  return ListView.separated( itemCount: list.length,
  itemBuilder: (context,index){
      return ListTile(
        title: Text(list[index]),
        onTap: (){
            onSelectNext(context,index);
        },
      );
  },separatorBuilder:(context,index){
      return Divider(
        color: Colors.black12,
        height: 1,
      );
  });

}

void onSelectNext(BuildContext context, int index) {
  Navigator.of(context).push(MaterialPageRoute(builder: (context) {
    if(index ==0){
      return  PaddingPage();
    }else if(index ==1){
      return DecoratedBoxPage();
    }else if(index ==2){
      return TransformPage();
    }else if(index ==3){
      return ContainerPage();
    }else if(index ==4){
      return ClipPage();
    }else if(index ==5){
      return FittedBoxPage();
    } else {
      return PaddingPage();
    }
  }));
}


